<?xml version="1.0" encoding="UTF-8"?>
<transfer xsi:noNamespaceSchemaLocation="/transfer/resources/xsd/transfer.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<objectDefinitions>
		<package name="user">
          	<object name="user" table="users" >
				<id name="user_id" type="numeric" generate="false"/>
				<property name="username" type="string" nullable="false" />
				<property name="password" type="string" nullable="false" />
				<onetomany name="attempt">
				    <link to="exam.attempt" column="attempt_id"/>
					<collection type="struct"><key property="attempt_id" /></collection>			  
				</onetomany>

				<manytomany name="userExams" table="user_exam">
					<link to="user.user" column="user_id" />
					<link to="exam.exam" column="exam_id"/>
					<collection type="struct"><key property="exam_id" /></collection>			  
				</manytomany>
				<!-- attempt 1 & 3 
				<onetomany name="userExams" lazy="true">
					<link to="exam.user_exam" column="user_id" />
					<collection type="struct"><key property="user_id" /></collection>			  
				</onetomany>
				-->
         	</object>
      	</package>
		<package name="exam">
			<object name="exam" table="exam" >
		        <id name="exam_id" type="numeric" generate="false"/>
				<property name="name" type="string" nullable="false" />
				<property name="description" type="string" nullable="true" />
				<onetomany name="question" lazy="true">
					<link to="exam.question" column="exam_id"/>
					<collection type="struct"><key property="exam_id" /></collection>			  
				</onetomany>
				<!--
				<manytomany name="users" table="user_exam" lazy="true">
					<link to="user.user" column="user_id" />
					<link to="exam.exam" column="exam_id"/>
					<collection type="struct"><key property="user_id" /></collection>			  
				</manytomany>
				-->
				<!-- FTJ | this doesn't make sense you want to get '
				<onetomany name="users" lazy="true">
					<link to="exam.user_exam" column="exam_id" />
					<collection type="struct"><key property="exam_id" /></collection>			  
				</onetomany>
				-->
			</object>
	        <object name="answer" table="answer" >
				<id name="answer_id" type="numeric" generate="false"/>
				<property name="answer" type="string" nullable="false" />
				<property name="question_id" type="numeric" nullable="false" />
				<property name="is_correct" type="boolean" nullable="false" />
        	</object>
        	<object name="attempt" table="attempt" >
				<id name="attempt_id" type="numeric" generate="false"/>
				<property name="is_finish" type="boolean" nullable="false" />
				<property name="final_mark" type="numeric" nullable="false" />
				<property name="user_id" type="numeric" nullable="false" />
				<onetomany name="attempt_question" lazy="true">
					<link to="exam.attempt_question" column="attempt_id" />
					<!-- <collection type="struct"><key property="attempt_id" /></collection> -->
					<collection type="array"><order property="attempt_id" order="asc" /></collection>			  
				</onetomany>
        	</object>
          	<object name="question" table="question" >
				<id name="question_id" type="numeric" generate="false"/>
				<property name="question" type="string" nullable="false" />
				<property name="exam_id" type="numeric" nullable="false" /><!-- 17/01/2009 -->
				<onetomany name="answers">
					<link to="exam.answer" column="question_id"/>
					<!--<collection type="struct"><key property="question_id" /></collection>-->
					<collection type="array"><order property="question_id" order="asc" /></collection>			  
				</onetomany>
				<onetomany name="attempt_question" lazy="true">
					<link to="exam.attempt_question" column="question_id"/>
					<!-- <collection type="struct"><key property="question_id" /></collection> -->
					<collection type="array"><order property="question_id" order="asc" /></collection>			  
				</onetomany>			  
			</object>
			<object name="attempt_question" table="attempt_question">
				<compositeid>
					<parentonetomany class="exam.attempt" />
					<parentonetomany class="exam.question" />
	    		 </compositeid>
	    		 <property name="attempt_id" type="numeric" />
	    		 <property name="question_id" type="numeric" />
				 <property name="user_answer_ids" type="string" nullable="false" />
	             <property name="is_correct" type="boolean" nullable="false" />
		  	</object>
		  	
				<!-- 
			<object name="user_exam" table="user_exam">
				
				attempt 1
				<compositeid>
			   		<parentonetomany class="user.user" />
			   		<parentonetomany class="exam.exam" />
			 	</compositeid>
			 	-->
			 	<!-- attempt 3 - caused memory leak 
				<compositeid>
			   		<manytoone name="user" />
			   		<manytoone name="exam" />
			 	</compositeid>			 	
			 	<manytoone name="user">
			 		<link to="user.user" column="user_id" />
			 	</manytoone>
			 	<manytoone name="exam">
			 		<link to="exam.exam" column="exam_id" />
			 	</manytoone>
			</object>
			 	
			 	-->
    	</package>
	</objectDefinitions>
</transfer>
